(function () {
    $.ajax({
            url: 'http://chst.vip:1234/api/getbrandtitle'
        })
        .then(res => {
            // console.log(res);
            render(res.result)
        })

    function render(data = []) {
        data = [...data]
        // console.log(data);
        let page = ''
        data.forEach(item => {
            // console.log(item.brandTitleId);
            page += `
            <div class="panle-group-10" brandtitleid = "${item.brandTitleId}">
                <div>
                    ${item.brandTitle}
                </div>
                <span>&#9660;</span>
            </div>
            <div class="panle-group-10-10">
            </div>
            `
        })
        $('#panle-group').html(page)
    }
    $('#panle-group').on('click', '.panle-group-10', function () {
        let titleid = $(this).attr('brandtitleid')
        // console.log(titleid);
        $.ajax({
                url: `http://chst.vip:1234/api/getbrand?brandtitleid=${titleid}`
            })
            .then(res => {
                let newData = [...res.result]
                console.log(newData);
                let page1 = ''
                let count = 0
                newData.forEach(item => {
                    count++
                    page1 += `
                <div class="panle-group-10-10-10" brandid = "${item.brandTitleId}" title = "${item.brandName}">
                    <i>${count}</i>
                    <span>${item.brandName}</span>
                    <p>${item.brandInfo}</p>
                </div>
                `
                })
                $('.panle-group-10-10').eq($(this).index('.panle-group-10')).slideToggle().html(page1)
            })
        $('.panle-group-10-10').on('click', '.panle-group-10-10-10', function () {
            let brandid = $(this).attr('brandid')
            let title = $(this).attr('title')
            location.href = `../pages/brand.html?title=${title}&brandtitleid=${brandid}`
        })
    })
})()